﻿<html>
<head>
	<title>Blog to BBCode Options</title>
	<link href='ti.blogbb.options.css' rel='stylesheet' type='text/css'/>
	<script src='library/ti.js' type='text/javascript'></script>
	<script src='ti.blogbb.options.js' type='text/javascript'></script>
	<script type='text/javascript'>
		dom.ready(function(e) {
			dom.get('url').value = options.url.blog;
			dom.get('color').value = options.backColor;
			dom.get('blog-title').html((options.title) ? options.title : 'Blog Connection');
			dom.get('save-button').onClick(function(e) {
				var url = dom.get('url').value;
				var color = dom.get('color').value;
				
				if (/[A-Za-z]{2,}\.[A-Za-z]{2,}/.test(url)) {
					if (!(/^http:\/\//.test(url))) { url = 'http://' + url; }
				} else {
					alert('Please enter the address of a blog feed');
					return;
				}
				if (!(/([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/.test(color))) {
					alert('Please enter a hexadecimal color value');
					return;
				}
				options.parse(url, color, function(message) {
					if (message) {
						alert(message);
					} else {
						dom.get('blog-title').html(options.title);
						alert('Settings have been saved');
					}
				});
			});
		});
	</script>
</head>
<body>
	<form>
		<fieldset id='login'>
			<legend id='blog-title'></legend>
			<label for='url'>Address</label><input type='text' id='url'/><br/>
			<label for='color'>Background color</label><input type='text' id='color'/>
			<input type='button' id='save-button' value='Save'/>
		</fieldset>
	</form>
</body>